<?php

class ContestTypeHandler {

    public static $_handlers;

    public $controller;
    public $contestTypeName;

    public static function getHandler($param){
        $class = __CLASS__;
        $handler = new $class();
        $handler->contestTypeName = $param->contesttype->name;
        $handler->controller = Yii::app()->controller;
        return $handler;
    }

    public function getContestTypePathAlias(){
        return 'ext.contest.types.'.$this->contestTypeName;
    }

    public function install() {
        Yii::import($this->getContestTypePathAlias() . '.Installer');
        echo Installer::install();
    }

    public function initiate($contest) {
        Yii::import($this->getContestTypePathAlias() . '.Initiator');
        echo Initiator::init($contest , $this);
    }

    public function rankViewWidget($properties) {
        $this->controller->widget($this->getContestTypePathAlias().'.widgets.'.ucfirst($this->contestTypeName).'RankViewWidget', $properties);
    }
}
